package lesson3.pages;

import lesson3.api.ApplicationManager;
import lesson3.api.models.UserModel;
import lesson3.pages.locators.page.IndexPageLocators;

public class IndexPage extends PageBase
{
	private final IndexPageLocators locators;

	public IndexPage(ApplicationManager p_app)
	{
		super(p_app);
		locators = new IndexPageLocators(p_app);
	}

	private void fillLoginData(UserModel p_userData)
	{
		// Login to site
		type(locators.txtLogin(), p_userData.login);
		type(locators.txtPassword(), p_userData.password);
	}

	private void submitLoginData()
	{
		// Submit login data
		click(locators.btnLogin());
	}

	public void openRegistrationPage()
	{
		// Open the registration page
		click(locators.linkRegistration());
	}

	public void login(UserModel p_userData)
	{
		fillLoginData(p_userData);
		submitLoginData();
	}

	public boolean isNotification()
	{
		return isElementPresent(locators.blockNotification());
	}
}
